using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_TripParam {
		#region Fields
		private int iD;
		private string text;
		private string type;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_TripParam class.
		/// </summary>
		public TF_TripParam() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_TripParam class.
		/// </summary>
		public TF_TripParam(string text, string type) {
			this.text = text;
			this.type = type;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_TripParam class.
		/// </summary>
		public TF_TripParam(int iD, string text, string type) {
			this.iD = iD;
			this.text = text;
			this.type = type;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the Text value.
		/// </summary>
		public string Text {
			get { return text; }
			set { text = value; }
		}
		
		/// <summary>
		/// Gets or sets the Type value.
		/// </summary>
		public string Type {
			get { return type; }
			set { type = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_TripParam table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_TripParamInsert", text, type));
		}
		
		/// <summary>
		/// Updates a record in the TF_TripParam table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_TripParamUpdate", iD, text, type);
		}
		
		/// <summary>
		/// Deletes a record from the TF_TripParam table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_TripParamDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_TripParam table.
		/// </summary>
		public static TF_TripParam Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_TripParamSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_TripParam(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_TripParam table.
		/// </summary>
		public static List<TF_TripParam> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_TripParamSelectAll")) {
				List<TF_TripParam> tF_TripParamList = new List<TF_TripParam>();
				while (dataReader.Read()) {
					TF_TripParam tF_TripParam = MakeTF_TripParam(dataReader);
					tF_TripParamList.Add(tF_TripParam);
				}
				return tF_TripParamList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_TripParam class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_TripParam MakeTF_TripParam(SqlDataReader dataReader) {
			TF_TripParam tF_TripParam = new TF_TripParam();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_TripParam.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_TripParam.Text = dataReader.GetString(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_TripParam.Type = dataReader.GetString(2);
			}

			return tF_TripParam;
		}
		#endregion
	}
}
